package com.qf.day10.homework;

import java.util.Date;

/**
 * 替换字符串的叠字
 * 例如，对于字符串 "hello nice to meet you"
 * 将其中出现两次的字符 ll 和 ee 分别替换为 l~ 和 e~
 * 输出为：hel~o nice to me~t you
 *"浩浩荡荡"
 * 输出为： 浩~荡~
 */

public class Homework02 {
    public static void main(String[] args) {
        String s = "hello nice to meet you";
        String a= "浩浩荡荡";
        String r = dealStr(s);
        String b = dealStr(a);
        System.out.println(r);
        System.out.println(b);

    }

    private static String dealStr(String s) {
        String reg = "([a-zA-Z\\u4e00-\\u9fa5])\\1";
        String s1 = s.replaceAll(reg, "$1~");
        return s1 ;
    }

}
